#pragma once

#include <string>
#include <functional>

#include "Control_Base.h"
//#include "WindowComponent.h"
#include "RendererComponent.h"

namespace gui
{
	class Control_Interface : public Control_Base
	{
		friend Host;

	public:
		Control_Interface(
			std::function <void()> NewRefreshFunction,
			std::function <void(RendererComponent& Renderer)> NewUpdateVerticesFunction,
			std::function <void()> NewMouseMoveFunction,
			std::function <void()> NewMouseDownLeftFunction,
			std::function <void()> NewMouseUpLeftFunction,
			std::function <void()> NewMouseDownRightFunction,
			std::function <void()> NewMouseUpRightFunction,
			Host& NewParentHost);

		Control_Interface(Host& NewParentHost);

		virtual ~Control_Interface();
	
		void SetRefreshFunction(std::function <void()> NewRefreshFunction){ RefreshFunction = NewRefreshFunction; };
		void SetUpdateVerticesFunction(std::function <void(RendererComponent& Renderer)>NewUpdateVerticesFunction){ UpdateVerticesFunction = NewUpdateVerticesFunction; };
		void SetMouseMoveFunction(std::function <void()> NewMouseMoveFunction){ MouseMoveFunction = NewMouseMoveFunction; };
		void SetMouseDownLeftFunction(std::function <void()> NewMouseDownLeftFunction){ MouseDownLeftFunction = NewMouseDownLeftFunction; };
		void SetMouseUpLeftFunction(std::function <void()> NewMouseUpLeftFunction){ MouseUpLeftFunction = NewMouseUpLeftFunction; };
		void SetMouseDownRightFunction(std::function <void()> NewMouseDownRightFunction){ MouseDownRightFunction = NewMouseDownRightFunction; };
		void SetMouseUpRightFunction(std::function <void()> NewMouseUpRightFunction){ MouseUpRightFunction = NewMouseUpRightFunction; };


	private:
		void UpdateVerticesFast(RendererComponent& Renderer);

		virtual void Refresh();

		//events
		virtual void MouseMove();

		virtual void MouseDownLeft();
		virtual void MouseUpLeft();

		virtual void MouseDownRight();
		virtual void MouseUpRight();

		//virtual void KeyPressed();
		//virtual void KeyReleased();

		void SetFocus(bool NewFocus);

		//callbacks
		std::function <void()> RefreshFunction;
		std::function <void(RendererComponent& Renderer)> UpdateVerticesFunction;
		std::function <void()> MouseMoveFunction;
		std::function <void()> MouseDownLeftFunction;
		std::function <void()> MouseUpLeftFunction;
		std::function <void()> MouseDownRightFunction;
		std::function <void()> MouseUpRightFunction;

		StatusComponent& Status;

	};	
}